<template>
  <div class="chart_box">
    <Header :isSimMainWin="false" />
    <div class="_cb_main">
      <TimeSery />
    </div>
  </div>
</template>
<script lang="ts" setup>
import Header from "@/components/Header.vue";
import TimeSery from "./components/TimeSery.vue";
import { onMounted } from 'vue';
import { controller } from "@/engine/Controller";
import { ipcRenderer } from "electron";
import { SimFrameToSubChannel, SimSubwinMsgToSimWin } from "@/engine/types/Win";
import { SimulateStatusType } from "@/engine/_";

onMounted(async () => {
  controller.chartsService.init();
  ipcRenderer.on(SimFrameToSubChannel.SimStatusChange, (event: Event, data: SimulateStatusType) => {
    console.info('get sim-status: ', data);
    controller.chartsService.simStatus = data;
    if (data === SimulateStatusType.stop) {
      controller.chartsService.timeSeryService.updateTimeSeryChartStepOne();
    }
  });

  // end position
  controller.winService.simSubWinSendInfoToSimWin({ type: SimSubwinMsgToSimWin.SubMounted });
});

</script>
<style lang="scss" scoped>
.chart_box {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  ._cb_main {
    flex: auto;
  }
}
</style>
